<!--
 * @Author: HeAo
 * @Date: 2022-08-24 19:47:25
 * @LastEditTime: 2022-08-24 19:54:44
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \JavaScripe\day-13事件机制\10-键盘事件和输入事件.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <body>
    <input type="text" name="" id="inp">
    <script>
      var inp = document.getElementById('inp')
      // keyup 用户释放键盘上某个键时触发。
      inp.onkeyup = function (event) {
        // console.log(event.keyCode);
      }
      // 输入事件
      inp.addEventListener('textInput', function (event) {
        console.log(event.data);
        console.log(event.target.value);
      })
    </script>
  </body>
</body>

</html>